# __author__ = 'GuanFengyu'
from tkinter import *
from tkinter.ttk import *
import tkinter.filedialog as fd
import tkinter.messagebox as mb 

class BaseWindow():
    def __init__(self,window):
        self.window = window
        self.menubar = Menu(self.window)
        self.note = Notebook(self.window)
        # 将root的menu属性设置为menubar
        self.window['menu'] = self.menubar

        self.about_menu = Menu(self.menubar, tearoff=0)    # 1.创建一个Menu对象
        self.help = '联系我'
        self.about_menu.add_command(label=self.help, command=self.showHelp)    # 2. 给Menu对象添加
        
        # 将menubar的menu属性指定为about_menu，即about_menu为menubar的下拉菜单
        self.menubar.add_cascade(label='关于', menu=self.about_menu)    # 3.把这个Menu对象加入到menuBar中

        self.init_window()

    # 设置窗口，参数为对象
    def set_window(self,object = None):
       #self.filemenu.add_command(label=object.help, command=object.showHelp)
       self.window.config(menu=self.menubar)
       self.note.add(object.frame, text=object.text)
       self.note.pack()

    def init_window(self,x=600,y=330):
        self.window.title('杭州综合测试室新课题小组')    #窗口名
        # 获取屏幕像素，在屏幕中央显示
        screenwidth = self.window.winfo_screenwidth()
        screenheight = self.window.winfo_screenheight()
        self.window.geometry('%dx%d+%d+%d' % (x, y, (screenwidth - x) / 2 - 10, (screenheight - y) / 2 - 40))
        self.window.resizable(width=False, height=False)  # 不可最大化
    
    def showHelp(self):
       textAuthor = 'ST杭州新课题小组_基于判定表生成测试用例'
       mb.showinfo(title='author', message=textAuthor)






